<template>
  <div class="wholeView">
    <Dialog content="存增量收入口径：根据资产入网时间定义（新增量：本年1月1日（含）之后; 存增量：上年1月1日（含）到12月31日（含）; 存存量：上年1月1日（不含）前）"></Dialog>
    <div class="breadcrumb">
      <div class="breadItem" v-for="(item, index) in breadList" :key="index">
        <div @click="handle_back(item, index)">{{ item.areaName }}</div>
        <p v-if="index != breadList.length - 1">></p>
      </div>
    </div>
    <el-table :data="tableData" v-loading="tableLoading" :header-cell-style="{
                background: '#0070C0',
                color: '#ffffff'
            }" style="width: 100%">
      <el-table-column prop="displayName" align="center" label="区域">
        <template slot-scope="scope">
          <span class="area" @click="handleArea(scope.row)">{{
                        scope.row.displayName
                    }}</span>
        </template>
      </el-table-column>
      <el-table-column label="整体收入" align="center">
        <el-table-column prop="monthIncome" align="center" label="当月"></el-table-column>
        <el-table-column prop="monthHb" align="center" label="环比"></el-table-column>
      </el-table-column>
      <el-table-column label="存存量" align="center">
        <el-table-column prop="monthCcl" align="center" label="当月"></el-table-column>
        <el-table-column prop="cclHb" align="center" label="环比"></el-table-column>
      </el-table-column>
      <el-table-column label="存增量" align="center">
        <el-table-column prop="monthCzl" align="center" label="当月"></el-table-column>
        <el-table-column prop="czlHb" align="center" label="环比"></el-table-column>
      </el-table-column>
      <el-table-column label="新增量" align="center">
        <el-table-column prop="monthZl" align="center" label="当月"></el-table-column>
        <el-table-column prop="zlHb" align="center" label="环比"></el-table-column>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
// import { getWholeView } from "@/api/barCode/index";

import $barCodeApi from "@/api/barCode/index";
import Dialog from './dialog.vue'
export default {
  name: "wholeView",
  components: {
    Dialog
  },
  props: {
    form: {
      type: Object,
      default: {}
    }
  },
  data () {
    return {
      tableLoading: false,
      tableData: [],
      breadList: [
        {
          areaName: "嘉兴分公司",
          areaId: 5
        }
      ],
      areaId: ""
    };
  },
  created () { },
  mounted () { },
  methods: {
    getList () {
      this.tableData = [];
      this.tableLoading = true;
      let obj = Object.assign({}, this.form);
      if (this.areaId) {
        obj.areaId = this.areaId;
      }



      $barCodeApi.getWholeView({ ...obj }, res => {
        if (res.code == 0) {
          this.tableLoading = false;
          this.tableData = res.content;
        }
      });


      //   getWholeView(obj).then(res => {
      //     if (res.code == 0) {
      //       this.tableLoading = false;
      //       this.tableData = res.content;
      //     }
      //   });
    },
    handleArea (row) {
      if (Number(row.areaLvl) > 6) {
        return;
      }
      if (
        row.displayName ==
        this.breadList[this.breadList.length - 1].areaName
      ) {
        return;
      }
      let obj = {};
      obj.areaName = row.displayName;
      obj.areaId = row.areaId;
      this.breadList.push(obj);
      this.areaId = row.areaId;
      this.getList();
    },
    handle_back (item, index) {
      if (index == 0) {
        this.breadList = [
          {
            areaName: "嘉兴分公司",
            areaId: 5
          }
        ];
      }
      this.breadList.splice(index + 1, this.breadList.length - index);
      this.areaId = item.areaId;
      this.getList();
    }
  }
};
</script>

<style scoped>
.area {
  color: #1890ff;
  cursor: pointer;
}
.breadcrumb {
  margin-bottom: 10px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.breadItem {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.breadItem > div {
  margin-right: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}
.breadItem > p {
  padding: 0 10px;
  margin: 0;
}
.breadItem div:hover {
  color: #1890ff;
}
</style>
